<?php 

@session_start();

?>

<?php

$select = $_POST['select'];

//include "insertData.php";

$_SESSION['sel'] = $select; 

//check file type before insertion

  $allowedExt = array("csv");
  
  foreach ($_FILES as $file){
  
    if ($file['tmp_name'] > ''){
	
      if (!in_array(end(explode(".",strtolower($file['name']))),$allowedExt)){
	  
       die($file['name'].' is an invalid file type!<br/>'.
	   include('insertMultiple.php');

      }else{
	  
//the insertion done after validating the file type
	  
$uploadFile = @$_POST['uploadFile'];

//Where the file is going to be placed 
$target_path = "uploads/";

//$file_type = $_FILES["uploadFile"]["type"];

//Add the original filename to our target path.  
//Result is "uploads/filename.extension" 

$target_path = ($target_path . basename( $_FILES['uploadFile']['name']));

if(move_uploaded_file($_FILES['uploadFile']['tmp_name'], $target_path)) {

$msg = "File Upload successful";
header("location:insertMultiple.php?poll=$msg");

include('insertData.php');

  }

else{
   
//echo "<img src=\"$target_path\" width=\"150\" height=\"150\">";
   
$msg = "File Upload Failed!!, Please try again";
header("location:insertMultiple.php?poll=$msg");
  }


  
	  }

?>

